package com.siwei.mes.entity.experiment;

import cn.dev33.satoken.stp.StpUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;


/**
 * 试验台账快检信息(ExperimentQuickRecord)实体类
 *
 * @author linzi
 * @since 2023-12-24 21:44:10
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_experiment_quick_record")
@ApiModel(value = "ExperimentQuickRecord", description = "试验台账快检信息")
public class ExperimentQuickRecord implements Serializable {
    private static final long serialVersionUID = 737122883989512225L;
    /**
     * 主键id
     */
    @Id
    @ApiModelProperty(value = "试验台账快检信息主键ID", name = "id")
    private Long id;
    /**
     * 试验台账id
     */
    @Column(name = "experiment_id")
    @ApiModelProperty(value = "试验台账id", name = "experimentId")
    private Long experimentId;
    /**
     * 快检配置id
     */
    @Column(name = "quick_id")
    @ApiModelProperty(value = "快检配置id", name = "quickId")
    private Long quickId;
    /**
     * 结果 检测值
     */
    @Column(name = "result_value")
    @ApiModelProperty(value = "结果 检测值", name = "resultValue")
    private String resultValue;


    @Column(name = "is_qualified")
    @ApiModelProperty(value = "是否合格 0-未检测  1-合格 2-不合格")
    private Integer isQualified;

    /**
     * 图片  多个用逗号隔开
     */
    @Column(name = "img")
    @ApiModelProperty(value = "图片  多个用逗号隔开", name = "img")
    private String img;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  0-未删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  0-未删除  1-删除", name = "isDel")
    private Integer isDel;

    public ExperimentQuickRecord init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                .setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                    .setCreateTime(new Date()).setIsDel(0).setIsQualified(0);
        }
        return this;
    }

    public ExperimentQuickRecord erpInit(boolean isCreate) {
        this.setUpdateTime(new Date());
        if (isCreate) {
            this.setCreateTime(new Date()).setIsDel(0).setIsQualified(0);
        }
        return this;
    }

    public ExperimentQuickRecord tcInit(boolean isCreate) {
        this.setUpdateTime(new Date());
        if (isCreate) {
            this.setCreateTime(new Date()).setIsDel(0).setIsQualified(0);
        }
        return this;
    }
}
